﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices; 

namespace EasyStudy.tools
{
    public class Sound
    {
        public static uint SND_ASYNC = 0x0001;
        public static uint SND_FILENAME = 0x00020000; 

        [DllImport("winmm.dll")] 
　　    public static extern uint mciSendString(string lpstrCommand, 
　　    string lpstrReturnString, uint uReturnLength, uint hWndCallback); 

　　    public static void Play() 
　　    {
          if (!GlobalSettings.SoundOn)
          {
              return;
          }

　　　　    mciSendString(@"close temp_alias", null, 0, 0); 
　　　　    mciSendString(@"open ""ring.mp3"" alias temp_alias", null, 0, 0); 
        //mciSendString("play temp_alias repeat", null, 0, 0); 
            mciSendString("play temp_alias", null, 0, 0); 
　　    }

      public static void PlayFinish()
      {
          if (GlobalSettings.SoundOn)
          {
              mciSendString(@"close temp_alias", null, 0, 0);
              mciSendString(@"open ""finish.mp3"" alias temp_alias", null, 0, 0);
              //mciSendString("play temp_alias repeat", null, 0, 0); 
              mciSendString("play temp_alias", null, 0, 0);
          }
      }

      public static void Stop() 
      {
          mciSendString(@"close temp_alias", null, 0, 0);
      }
    }
}
